﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Management;
using System.Management.Instrumentation;
using System.Web.Mvc;
using System.Diagnostics;
using WMI = ROOT.CIMV2.Win32;

namespace sccmweb1.Controllers
{
    public class CollectionController : Controller
    {
        //
        // GET: /Collection/

        public ActionResult Index()
        {
            return View();
        }


        public ActionResult GetSubCollections()
        {
            var collections = new List<object>();
            collections.Add(new { Id = "U0000001", Name = "Install", Description = "for install" });
            collections.Add(new { Id = "U0000002", Name = "Install_2", Description = "for test install" });
            collections.Add(new { Id = "U0000003", Name = "Install_3s", Description = "for mass install" });
            collections.Add(new { Id = "U0000004", Name = "Install4", Description = "for install" });
            collections.Add(new { Id = "U0000005", Name = "Install_5t", Description = "for test install" });
            collections.Add(new { Id = "U0000006", Name = "Install_6", Description = "for mass install" });
            collections.Add(new { Id = "U0000007", Name = "Install7", Description = "for install" });
            collections.Add(new { Id = "U0000008", Name = "Install_8", Description = "for test install" });
            collections.Add(new { Id = "U0000009", Name = "Install_9", Description = "for mass install" });
            collections.Add(new { Id = "U0000011", Name = "Install11", Description = "for install" });
            collections.Add(new { Id = "U0000012", Name = "Install_12", Description = "for test install" });
            collections.Add(new { Id = "U0000013", Name = "Install_13s", Description = "for mass install" });
            collections.Add(new { Id = "U0000014", Name = "Install14", Description = "for install" });
            collections.Add(new { Id = "U0000015", Name = "Install_15t", Description = "for test install" });
            collections.Add(new { Id = "U0000016", Name = "Install_16", Description = "for mass install" });
            collections.Add(new { Id = "U0000017", Name = "Install17", Description = "for install" });
            collections.Add(new { Id = "U0000018", Name = "Install_18", Description = "for test install" });
            collections.Add(new { Id = "U0000019", Name = "Install_19", Description = "for mass install" });

            return Json(collections, JsonRequestBehavior.AllowGet);
        }


        public ActionResult GetProcess()
        {
            List<WMI.Process> collectionProcesses = WMI.Process.GetInstances().Cast<WMI.Process>().ToList();

            foreach (WMI.Process process in collectionProcesses)
            {
                var d = process.Caption;
                
            }

            return Json(collectionProcesses, JsonRequestBehavior.AllowGet);
        }


        public ActionResult TestSelect()
        {
            return View();
        }
    }
}